package com.mashibing.serviceverificationcode.controller;

import org.mashibing.dto.ResponseResult;
import org.mashibing.response.NumberCodeResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author: dujunhua
 * @create: 2024/3/19 16:32
 * @description:
 */
@RestController
public class NumberCodeController {

    /**
     * 获取数字验证码
     */
    @GetMapping("/numberCode/{size}")
    public ResponseResult numberCode(@PathVariable("size") int size){

        double mathRandom = (Math.random() * 9 + 1) * (Math.pow(10, size - 1));
        int resultInt = (int)mathRandom;
        NumberCodeResponse response = new NumberCodeResponse(resultInt);
        return ResponseResult.success(response);
    }


}
